<template>
  <div>
    <el-table :data="pageData" v-loading="loading" stripe :header-cell-style="tableHeaderStyle">
      <el-table-column label="序号" type="index" width="50"></el-table-column>
      <el-table-column prop="createTime" width="160" label="交易时间"></el-table-column>
      <el-table-column prop="orderNo" label="订单号"></el-table-column>
      <el-table-column prop="price" label="订单金额"></el-table-column>
      <el-table-column prop="payMoney" label="实付金额"></el-table-column>
      <el-table-column prop="refundMoney" label="分账金额"></el-table-column>
      <el-table-column prop="status" label="订单状态">
        <template slot-scope="scope">
          <span>{{scope.row.status | changeOrderStatus}}</span>
        </template>
      </el-table-column>
      <el-table-column prop="refundStatus" label="分账状态">
        <template slot-scope="scope">
          <span>{{scope.row.refundStatus | changeStatus}}</span>
        </template>
      </el-table-column>
    </el-table>
    <div class="text-center margin_top_20">
      <el-pagination @size-change="handleSizeChange" @current-change="handlePagingChange" :current-page="pageIndex" :page-sizes="pageSizes"
          :page-size="pageSize" :layout="paginationLayout" :total="pageCount">
        </el-pagination>
    </div>
  </div>
</template>

<script>
  import Setting from '@/settings';
  import { GetSharedSharerOneAccount } from  '@/views/shared-management/services/index';
  export default {
    props: {
      type: '',
      inviteeId: ''
    },
    data() {
      return {
        pageData: [],
        pageCount: 0,
        pageIndex: 1,
        loading: false,
        pageSize: Setting.defaultTablePaginationSize,
        pageSizes: Setting.tablePaginationSizes,
        tableHeaderStyle: Setting.tableHeaderStyle,
        paginationLayout: Setting.tablePaginationLayout
      }
    },
    
    watch:{
      type(newValue) {
        this.getPageDataList();
      },
      inviteId(newValue) {
        this.getPageDataList();
      }
    },
    filters: {
      changeStatus(val) {
        switch (val) {
          case 1:
            return '通过';
          case 2:
            return '拒绝';
          default:
            return '待审核';
        }
      }
    },
    methods:{
      getPageDataList() {
        this.loading = true;
        GetSharedSharerOneAccount({
          pageSize: this.pageSize,
          pageNum: this.pageIndex,
          refundType: this.type,
          inviteeId: this.inviteId,
          'targetId': this.$route.query.id
        })
        .then(data => {
          if(data.code == 200){
            this.pageData = data.data.list;
            this.pageCount = data.data.total;
          }
          this.loading = false;
        })
        .catch(error => {
          this.loading = false;
        })
      },
      // 分页操作
      handlePagingChange(event) {
        this.pageIndex = event;
        this.getPageDataList();
      },
      handleSizeChange(event) {
        this.pageIndex = 1;
        this.pageSize = event;
        this.getPageDataList();
      }
    },
    created() {
      this.getPageDataList();
    }
  }
</script>
